home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-07-15 | 3.2 KB | 137 lines | [TEXT/MPS ] |
- { HistogramIo.inc © Copyright G. Sawitzki, 1988-1991}
- {$S Histogram}
- const cTextSize=9;
- chunk=4;
- type tHistTable=array[0..maxclass] of extended;
-
- procedure PrepareHistHist(var xhist,yhist: histtype;var comprect:rect;contents:str15);
- const boundary=5;
- var
- temprect:rect;
- s:str255;
- begin
- temprect:=comprect;
- insetrect(temprect,-1,-1);framerect(temprect);
- eraserect(comprect);textsize(9);
- penNormal;
- with comprect do
- begin
- moveto(left,bottom);lineto(right,top);
- moveto(left+boundary,top+ctextsize+boundary);
- drawstring(concat(contents,' ',yhist.id));
-
- s:=concat(contents,' ',xhist.id);
- moveto(right-boundary-stringwidth(s),bottom-boundary);
- drawstring(s);
- end;
- end;
-
- procedure HistToTable(var hist:histtype; var DataPoint, DistrFunction:tHistTable);
- var i:integer;
- begin
- with hist do begin
- DistrFunction[0]:=cnt[0]/count;DataPoint[0]:=min+binwidth;
- for i:=1 to maxclass do
- begin
- DistrFunction[i]:=DistrFunction[i-1]+cnt[i]/count;
- DataPoint[i]:=min+(i+1)*binwidth;
- end;
- end;
- end;
-
-
- procedure showHistogram (var histogram: histtype; var histrect: rect;NumbForm: DecForm);
- const boundary=5;
- var
- i: longint;
- myhdle: pichandle;
- hilfreal, myfakty, myfaktx: extended;
- horsize, vertsize, xoffs, yoffs: integer;
- dstr: decstr;
- penwidth: integer;
- temprect:rect;
- begin
- pennormal;
- temprect:=histrect;
- insetrect(temprect,-1,-1);framerect(temprect);
- eraserect(histrect);textsize(cTextSize);
-
- with histogram, histrect do
- begin
- horsize := right - left;
- vertsize := bottom - top -cTextSize-3 * boundary;
-
- moveto(left + 2, bottom - 2);
- num2str(numbform, min, dstr);
- drawstring(dstr);
- num2str(numbform, max, dstr);
- moveto(right - 2 - stringwidth(dstr), bottom - 2);
- drawstring(dstr);
- moveto(left + (right - left - stringwidth(id)) div 2, bottom - 2);
- drawstring(id);
-
- penwidth := (horsize - 2) div (2 * maxclass + 1);
- if penwidth=0 then penwidth:=1;
- pensize(penwidth, penwidth);
-
- myfakty := vertsize / histogram.maxbincount;{••••}
- myfaktx := horsize / (maxclass + 1);
- with histrect do
- begin
- xoffs := left;
- yoffs := bottom - 2*boundary-cTextSize;
- end;
-
- for i := 0 to maxclass do
- if cnt[i] > 0 then
- begin
- hilfreal := myfakty * histogram.cnt[i];
- moveto(xoffs + i * round(myfaktx), yoffs);{•••}
- lineto(xoffs + i * round(myfaktx), yoffs - round(hilfreal));{•••}
- end;
- pennormal;
- moveto(xoffs, yoffs + penwidth);
- lineto(right, yoffs + penwidth);
- end;{with histogram}
- {framerect(histrect);}
- end;
-
-
- procedure ReportStat (var stat: tStatType; var r: rect; var form: DecForm);
- const
- xmargin = 2;
- ydelta = 12;
- var
- dstr: decstr;
- temp: extended;
- s:str255;
- begin
- with stat, r do
- begin
- eraseRect(r);textsize(9);
- moveto(left + xmargin, top + ydelta);
- num2str(form, min, dstr);
- drawstring(dstr);
-
- num2str(form, max, dstr);
- moveto(right - xmargin - stringwidth(dstr), top + ydelta);
- drawstring(dstr);
- moveto(left + (right - left - stringwidth(id)) div 2, top + ydelta);
- drawstring(id);
-
- moveto(left + xmargin, top + 2 * ydelta);
- drawstring('µ: ');
- num2str(form, mean, dstr);
- drawstring(dstr);
- if count > 1 then
- begin
- temp := sqrt(ssq / (count - 1));
- Num2Str(form, temp, dstr);
- drawstring(concat(' (', dstr, ')'));
- end;
- NumToString(count,s);
- drawstring(concat(' n=',s));
- end;
- end;
-
-